package com.example.datachange.controller;

import com.example.datachange.model.WorkOrderDetailResult;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * 女朋友控制器
 * @author zhouhao
 * @since  2021/9/30 12:49
 */
@RequestMapping("client")
@RestController
public class ClientController {

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("okhttp3")
    public WorkOrderDetailResult print() {
        String id = "1534343954060926978";
        ResponseEntity<WorkOrderDetailResult> data = restTemplate.postForEntity("http://www.zhou.com:8094/epoi/inspection/progress/workorder/detail/" + id, null, WorkOrderDetailResult.class);

        return data.getBody();
    }

    @GetMapping(value = "girlfriend", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE })
    public WorkOrderDetailResult girlfriend() {
        WorkOrderDetailResult r = new WorkOrderDetailResult();
        r.setSuccess(true);
        r.setCode(200);
        r.setMessage("成功");
        r.setWorkOrderDetail(new WorkOrderDetailResult.WorkOrderDetail());
        r.setInspectionContent(new WorkOrderDetailResult.InspectionContent());
        return r;
    }
}
